deal with captions and frames first. draw:text-box is a powerfull element in OOo, its GUI name is frame. And OOo use it to contain Captions
Since there is not a corresponding object in word, so we draw the text-box itself and its children separately. If it look like a Caption only frame
we'll adjust the text-box position to make it look pretty
-->
<!-- skip all not force draw children , must be first case -->
<xsl:when test="ancestor::draw:text-box and $force-draw='false' "/>
<xsl:when test="name() = 'draw:text-box'">
<!-- draw the text-box itself -->
<w:r>
<w:pict>
<xsl:variable name="text-y-adjust">
<xsl:choose>
<xsl:when test="count(text:p/draw:*) = 1 and (string-length(text:p/draw:*[position()=1]/@svg:x) =0 or number(concat('0',translate(text:p/draw:*[position()=1]/@svg:x,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','') ))=0) and (string-length(text:p/draw:*[position()=1]/@svg:y)=0 or number(concat('0',translate(text:p/draw:*[position()=1]/@svg:x,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','') ))=0 ) ">
<xsl:variable name="pic-height">
<xsl:choose>
<xsl:when test="name(text:p/draw:*[position()=1]) = 'draw:g' or name(text:p/draw:*[position()=1]) = 'draw:a'">
<!-- for these need fill, set the default color we used in oo-->
<xsl:when test="name()='draw:polygon' or name()='draw:custom-shape' or name() = 'draw:rect' or (name() = 'draw:ellipse' and not( @draw:kind='arc') )">#00B8FF</xsl:when>
<!-- image special: convert oo base64 binary data (77char/line) to word base64 binary data(73char/line) , a workthrough is removing all line breaks -->
<xsl:if test="$ooshapename='path' or string-length(@svg:d) > 0 or ( $ooshapename='custom-shape' and draw:enhanced-geometry[1]/@draw:predefined-type = 'non-primitive') ">
<xsl:variable name="path">
<xsl:choose>
<xsl:when test="$ooshapename='path' or string-length(@svg:d) > 0 ">